import request from "../../utils/request";
const app = getApp();
// pages/wallet/wallet.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
    talExpense: "",
    talRecharge: "",
    closeeye: false,
    balance: "",
    moneyList: [
      { price: 0.01 },
      { price: 0.02 },
      { price: 0.03 },
      { price: 0.04 },
      { price: 0.05 },
      { price: 0.02 },
    ],
    value: "",
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      talExpense: options.talExpense,
      talRecharge: options.talRecharge,
      balance: options.balance,
    });
  },
  goback() {
    wx.navigateBack({
      delta: 1,
    });
  },
  chengeEye() {
    this.setData({
      closeeye: !this.data.closeeye,
    });
  },
  async goPay() {
    const res = await request({
      url: app.globalData.baseURL + "/app-user-api/pay/wallet-recharge/create",
      method: "POST",
      data: {
        payPrice: this.data.value * 100,
      },
    });
    if (res.code === 0) {
      wx.navigateTo({
        url: `/pages/paymethod/paymethod?price=${this.data.value * 100}&payOrderId=${
          res.data.payOrderId
        }&id=${res.data.id}`,
      });
    } else {
      wx.showToast({
        title: res.msg,
        icon: "none",
      });
    }
  },
  blurMethod(event) {
    this.setData({
      value:event.detail.value
    })
  },
  goWalletDetail(){
    wx.navigateTo({
      url: '/pages/walletDetail/walletDetail',
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function (options) {
    return {
      title: "嘉之勤官网小程序",
      path: "/pages/index/index",
      imageUrl:
        "https://youyougo2.oss-cn-chengdu.aliyuncs.com/0201506f6fc0f4145e34159c2e2ac66b94b96450dd29e5a19d177edc5dad8023.png",
    };
  },
});
